package danebrown;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;

import com.github.javaparser.JavaParser;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
import com.github.javaparser.ast.body.MethodDeclaration;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.expr.MemberValuePair;
import com.github.javaparser.ast.expr.NormalAnnotationExpr;
import com.github.javaparser.ast.expr.SingleMemberAnnotationExpr;
import com.github.javaparser.ast.expr.StringLiteralExpr;

/**
 * Java注解解析器
 * 用于读取目录下的Java文件并提取Spring注解信息
 */
public class AnnotationParser {

    /**
     * API信息数据类
     */
    public static void main(String[] args) {
        String scanPath = args.length > 0 ? args[0] : ".";
        String timestamp = String.valueOf(System.currentTimeMillis());
        String csvFileName = "系统调用关系" + timestamp + ".xlsx";

        try {
            ScanFeignPost.scan(scanPath, csvFileName);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        AstAnnotationParser.scan(scanPath, csvFileName);
//        OpenAPIParser.scan(csvFileName);

        XlsxWriter.finish();

    }
}